package main

import (
	"os"
	"os/exec"

	"github.com/spf13/cobra"
)

const raidTool = "tools/ssacli"

// 执行获取物理磁盘列表命令
func runssacliGetPdList(cmd *cobra.Command, args []string) error {
	toolPath, err := extractTool(raidTool)
	if err != nil {
		return err
	}

	ssacliCmd := exec.Command(toolPath, "ctrl", "slot=0", "pd", "all", "show")

	ssacliCmd.Stdin = os.Stdin
	ssacliCmd.Stdout = os.Stdout
	ssacliCmd.Stderr = os.Stderr

	return ssacliCmd.Run()
}

// 执行获取逻辑磁盘列表命令
func runssacliGetLdList(cmd *cobra.Command, args []string) error {
	toolPath, err := extractTool(raidTool)
	if err != nil {
		return err
	}

	ssacliCmd := exec.Command(toolPath, "ctrl", "slot=0", "ld", "all", "show")
	ssacliCmd.Stdin = os.Stdin
	ssacliCmd.Stdout = os.Stdout
	ssacliCmd.Stderr = os.Stderr

	return ssacliCmd.Run()
}
